load count.dat
c3=count(:,3);%Data at intersection 3
c3NaNCount=sum(isnan(c3))
bin_counts=hist(c3);
N=max(bin_counts);
mu3=mean(c3);
sigma3=std(c3)
(1:2)*sigma3

hist(c3) %Plot histogram
hold on
plot([mu3 mu3],[0 N],'r','LineWidth',2) %mean
X=repmat(mu3+(1:2)*sigma3,2,1);
Y=repmat([0;N],1,2);
plot(X,Y,'g','LineWidth',2)%Standard deviations
legend('Data','Mean','stds')
hold off
outliers=(c3-mu3) > 2*sigma3
c3m=c3; %Copy c3 to c3m
c3m(outliers)=NaN;%Add NaN values
plot(c3m,'o-')
hold on
span=3;
window=ones(span,1)/span;
smoothed_c3m = convn(c3m,window,'same');
h=plot(smoothed_c3m,'ro-');
legend('Data','Smoothed Data')

smoothed2_c3m = filter(window,1,c3m);

delete(h);
plot(smoothed2_c3m,'go-','DisplayName','Smoothed Data');
hold off